package cn.enited.devtools.apiaggregator.api.vo;

import cn.enited.devtools.apiaggregator.consts.CommonConst;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
public class ApiParameter implements Serializable {
    private static final long serialVersionUID = -1748769798082118529L;

    // 参数名，如果是接口返回值则name不带@
    private String name;

    // 参数来源：0=request body, 1=request head, 2=depend-api response
    private int source;

    // 参数类型：0=原始类型int、long、double、string等, 1=对象(Java对象或者JSON对象), 2=JSON数组
    private int type;

    // 数组参数的指定取值索引
    private Integer arrayIndex;

    // 对象类型参数的取值字段
    private ApiParameter field;

    public static ApiParameter empty() {
        return new ApiParameter();
    }

    public boolean isEmpty() {
        return StrUtil.isBlank(name);
    }

    public boolean isNotEmpty() {
        return StrUtil.isNotBlank(name);
    }
}